package com.zlx.exchange.address.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zlx.exchange.address.dao.AddressDao;
import com.zlx.exchange.address.service.AddressService;
import com.zlx.exchange.domain.entity.Address;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageInfo;

import javax.annotation.Resource;

import org.springframework.http.ResponseEntity;
import com.github.pagehelper.PageHelper;
import org.springframework.transaction.annotation.Transactional;

/**
 * 地区表(Address)表服务实现类
 *
 * @author makejava
 * @since 2023-09-04 20:29:18
 */
@Transactional
@Service("addressService")
public class AddressServiceImpl implements AddressService {
    @Resource
    private AddressDao addressDao;

    /**
     * 找出省市自治区
     * @return
     */
    public ResponseEntity<?> findProvince(){
        return ResponseEntity.ok(addressDao.selectList(new LambdaQueryWrapper<Address>().eq(Address::getRegionLevel,1)));
    }

    /**
     * 找出省下的市区县
     * @param regionFatherId
     * @return
     */
    public ResponseEntity<?> findRegion(String regionFatherId)
    {
        return ResponseEntity.ok(addressDao.selectList(new LambdaQueryWrapper<Address>().eq(Address::getRegionParentId,regionFatherId)));
    }
    /**
     * 找出具体地址
     */
    public ResponseEntity<?> findReginById(String id)
    {
        return ResponseEntity.ok(addressDao.selectById(id));
    }
}
